package com.aabte.design.pattern.behavioral.visitor;

import java.util.ArrayList;
import java.util.List;

public class Test {

    public static void main(String[] args) {

        List<Course> courseList = new ArrayList<>();

        FreeCourse freeCourse = new FreeCourse();
        freeCourse.setName("Shell脚本");

        CodingCourse codingCourse = new CodingCourse();
        codingCourse.setName("Java");
        codingCourse.setPrice(999);
        codingCourse.setSales(108);

        courseList.add(freeCourse);
        courseList.add(codingCourse);

        for (Course course: courseList) {
            // 将访问者传入，根据课程类型不同调用不同访问者方法
            course.accept(new Visitor());
        }

        for (Course course: courseList) {
            // 访问者是Boos
            course.accept(new BossVisitor());
        }


    }

}
